#ifndef _HASHMAP_H
#define _HASHMAP_H

/* #include <limits.h> */

#include "../Globals/_cdslib_globals.h"
#include "../Vector/_Vector.h"
#include "../Array/_Array.h"
#include "../Pair/_Pair.h"

/* HashMap structure */
typedef struct {
    size_t length;
    size_t keySize;
    int    (*compare)(const void *keyOne, const void  *keyTwo);
    size_t (*hash)   (const void *key,    const size_t keySize);
    Vector buckets;
} HashMap;

/* Function prototypes */
void  initHashMap   (HashMap *initThis,
                     size_t   keySize,
                     size_t (*hashKey)   (const void  *key, 
                                          const size_t keySize),
                     int    (*compareKey)(const void  *keyOne, 
                                          const void  *keyTwo));
Array deleteHashMap(HashMap *deleteThis);

void *HashMapGet        (HashMap *h, void *key);
Pair  HashMapSet        (HashMap *h, void *key, void *value);
Pair  HashMapExtract    (HashMap *h, void *key);
int   HashMapContainsKey(HashMap *h, void *key);

Array   _deleteHashMapIntoKeysAndValues(HashMap *h);
Vector *_getBucket                     (HashMap *h, void *key);
void    _HashMapResize                 (HashMap *h);
int     _HashMapAdd                    (HashMap *h, void *key, 
                                                     void *addThis);

#endif
